import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout',
  },
  {
    path: '/keep-alive',
    name: 'KeepAlive',
    component: () => import(/* webpackChunkName: "about" */ '../views/keep-alive/index.vue'),
  },
  // 动态路由
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import(/* webpackChunkName: "about" */ '../views/detail/index.vue'),
  },
  {
    path: '/city',
    name: 'City',
    component: () => import(/* webpackChunkName: "about" */ '../views/City.vue'),
  },
  {
    path: '/layout',
    name: 'Layout',
    component: () => import(/* webpackChunkName: "about" */ '../layouts/index.vue'),
    redirect: '/layout/findHome',
    children: [
      {
        path: 'findHome',
        name: 'FindHome',
        component: () => import(/* webpackChunkName: "about" */ '../views/FindHome.vue'),
      },
      {
        path: 'assist',
        name: 'Assist',
        component: () => import(/* webpackChunkName: "about" */ '../views/Assist.vue'),
      },
      {
        path: 'message',
        name: 'Message',
        component: () => import(/* webpackChunkName: "about" */ '../views/Message.vue'),
      },
      {
        path: 'mine',
        name: 'Mine',
        component: () => import(/* webpackChunkName: "about" */ '../views/Mine.vue'),
      },
    ],
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
